const path = require('path');
const webpack = require('webpack');

const svgDirs = [
    //require.resolve('antd-mobile').replace(/warn\.js$/, ''),  // 1. 属于 antd-mobile 内置 svg 文件
    path.resolve(__dirname, 'src/main/webapp/pages/mobile/font/svgs'),  // 2. 自己私人的 svg 存放目录
];
module.exports = {
    /*context: path.resolve(__dirname, './src/main/webapp/js/pages/sys/statistic/'),
    entry: {
        call: './call.jsx',
    },
    output: {
        path: path.resolve(__dirname, './src/main/webapp/js/pages/sys/statistic/'),
        filename: '[name].js',
    },*/

    module: {
        rules: [
            {
                test: /\.jsx$/,
                exclude: [/node_modules/],
                use: [{
                    loader: 'babel-loader',
                    options: {
                        presets: ['es2015', 'react','stage-1'],
                        "plugins": [
                            'transform-runtime',
                            'transform-decorators-legacy',
                            'transform-decorators',
                            ['import',
                                {
                                    libraryName: 'antd-mobile',
                                    style: 'css'
                                }
                            ]
                        ]
                    },
                }],
            },
            {
                test: /\.css$/,
                use: ['style-loader', 'css-loader'],
            },
            {
                test: /\.(svg)$/i,
                use: ['svg-sprite-loader'],
                include:svgDirs
            }
        ],
    },
    externals: {
        "react": 'React',
        'react-dom': 'ReactDOM',
        'echarts' : 'echarts'
    },
    resolve: {
        extensions: ['.web.js', '.js', '.json'],
    },
};